package org.tacademy.basic.calendar.databasemanager;

import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.util.Log;

public class ScheduleRequest extends DBRequest {

	boolean flag = false;
	int mYear, mMonth, mDay;
	
	Cursor cursor;
	
	public ScheduleRequest(){
		flag = false;
	}
	
	public ScheduleRequest(int year, int month, int day){
		mYear = year;
		mMonth = month;
		mDay = day;
		flag = true;
	}
	
	@Override
	protected void processQuery(SQLiteDatabase db) {
		// TODO Auto-generated method stub
		String[] columns = {DBConstant.ScheduleTable.ID, DBConstant.ScheduleTable.TITLE, 
				DBConstant.ScheduleTable.DATE, DBConstant.ScheduleTable.TIME, 
				DBConstant.ScheduleTable.CONTENT, DBConstant.ScheduleTable.LOCATION};
		String selection = DBConstant.ScheduleTable.DATE +" = ?";
		String[] selectionArgs = {""+mYear+"-"+mMonth+"-"+mDay};
		
		if(flag == true){
			cursor = db.query(DBConstant.ScheduleTable.TABLE_NAME, columns, selection, selectionArgs, null, null, null);
		}else{
			cursor = db.query(DBConstant.ScheduleTable.TABLE_NAME, 
					columns, null, null, null, null, null);
		}
	}

	@Override
	public Object getResult() {
		// TODO Auto-generated method stub
		return cursor;
	}

}
